﻿using Pdelvo.Minecraft.Network;

namespace Pdelvo.Minecraft.Protocol.Packets
{
    /// <summary>
    /// 
    /// </summary>
    /// <remarks></remarks>
    public class UpdateHealth : Packet
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="UpdateHealth"/> class.
        /// </summary>
        /// <remarks></remarks>
        public UpdateHealth()
        {
            Code = 0x08;
        }

        /// <summary>
        /// Gets or sets the health.
        /// </summary>
        /// <value>The health.</value>
        /// <remarks></remarks>
        public short Health { get; set; }
        /// <summary>
        /// Gets or sets the food.
        /// </summary>
        /// <value>The food.</value>
        /// <remarks></remarks>
        public short Food { get; set; }
        /// <summary>
        /// Gets or sets the food saturation.
        /// </summary>
        /// <value>The food saturation.</value>
        /// <remarks></remarks>
        public float FoodSaturation { get; set; }

        /// <summary>
        /// Receives the specified reader.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <param name="version">The version.</param>
        /// <remarks></remarks>
        public override void Receive(BigEndianStream reader, int version)
        {
            Health = reader.ReadShort();
            Food = reader.ReadShort();
            FoodSaturation = reader.ReadFloat();
        }

        /// <summary>
        /// Sends the specified writer.
        /// </summary>
        /// <param name="writer">The writer.</param>
        /// <param name="version">The version.</param>
        /// <remarks></remarks>
        protected override void Send(BigEndianStream writer, int version)
        {
            writer.Write(Code);
            writer.Write(Health);
            writer.Write(Food);
            writer.Write(FoodSaturation);
        }
    }
}